﻿@model CID.Web.Models.Users.UserViewModel
@using CID.Web.Support

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <div id="Tabs">
        <ul>
            <li><a href="#General">General</a></li>
            <li><a href="#Roles">Roles</a></li>
        </ul>
        <div id="General">
            <div class="editor-label">
                @Html.LabelFor(model => model.Name)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Name)
                @Html.ValidationMessageFor(model => model.Name)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.UserName)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.UserName)
                @Html.ValidationMessageFor(model => model.UserName)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Email)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Email)
                @Html.ValidationMessageFor(model => model.Email)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Enabled)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Enabled)
                @Html.ValidationMessageFor(model => model.Enabled)
            </div>
        </div>

        <div id="Roles">
            <div class="editor-field">
                <ul id="rolesEditor" style="list-style-type:none">
                    @for (int i = 0; i < Model.AssignedRoles.Count; i++)
                    {
                        <li>
                            @Html.CheckBoxFor(x => x.AssignedRoles[i].Assigned)
                            @Html.DisplayFor(x => x.AssignedRoles[i].UserRole)
                            @Html.HiddenFor(x => x.AssignedRoles[i].UserRole)
                        </li>
                    }
                </ul>
                @Html.ValidationMessageFor(model => model.AssignedRoles)
            </div>
        </div>
    </div>
    @Html.HiddenFor(model => model.Id)

    <p>
        <input type="submit" value="Save" />
    </p>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

<script type="text/javascript">
    $(document).ready(function () {
        $("#Tabs").tabs();
    });
</script>